<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Application_Filter_CleanHTML
 *
 * @author Dellano
 */

class Application_Filter_CleanHTML implements Zend_Filter_Interface
{
    /**
     * @var HTMLPurifier holds the instance of the purifier
     */
    protected $_purifier = null;

    /**
     * Filters the item
     * @param string $value
     * @return string filtered element
     */
    public function filter($value)
    {
        $this->_bootstrapPurifier();

     return $this->_purifier->purify($value);
     }

    /**
     * Start the purifier and store it locally
     */
    protected function _bootstrapPurifier()
    {
        if ($this->_purifier == null) {
         require_once 'htmlpurifier4/HTMLPurifier.auto.php';
         $config = HTMLPurifier_Config::createDefault();
         $config->set('Cache.SerializerPath', '../cache');
            $this->_purifier = new HTMLPurifier($config);
        }
    }
}
?>
